package com.zhu.service.util.handler;

import com.zhu.model.pojo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常捕捉
 */
@ControllerAdvice
public class GlobalException {


    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result fail(Exception e){
        e.printStackTrace();
        return Result.fail();
    }


    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public Result fail(BusinessException e){
        e.printStackTrace();
        return Result.fail().message(e.getMsg());
    }

}
